﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using COFE.Core.Filter;
using System.Drawing;
using System.IO;

namespace COFE.Core.EntryType
{
    /// <summary>
    /// Represent one type of entry, e.g. a SevenZip archive, a Text file, or a folder.
    /// </summary>
    public interface IEntryTypeInfo
    {
        /// <summary>
        /// Calculatable by EntryFilters, using FilterUtils.EntryFilterToString().
        /// </summary>
        Guid ID { get; }

        /// <summary>
        /// Used to define what entries this ETI applied to.
        /// </summary>
        IEntryFilter[] Filters { get; }

        /// <summary>
        /// Optional parameter obtained from ContentType in registry.
        /// </summary>
        string MIMEType { get; }

        /// <summary>
        /// Description of this entry type.
        /// </summary>
        string Description { get; }

    }

    public static class IEntryTypeInfoExtension
    {
        public static byte[] GetIconStream(this IEntryTypeInfo eti, IconProperties size)
        {
            return COFEShared.EntryTypeDictionary.IconExtractor.ConstructIcon(eti.Filters, size);
        }

        public static Bitmap GetIcon(this IEntryTypeInfo eti, IconProperties size)
        {
            return new Bitmap(new MemoryStream(eti.GetIconStream(size)));
        }
    }
}
